package com.nlscan.qdkit.ui.publico.util;

import android.graphics.Bitmap;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.nlscan.qdkit.common.core.app.App;
import com.quvii.qvlib.util.QvEasyBlur;

import java.security.MessageDigest;

public class GaussianBlurTransformation extends BitmapTransformation {

    @Override
    protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
        if (toTransform == null) {
            return null;
        }

        return QvEasyBlur.with(App.getInstance())
                .bitmap(toTransform) //要模糊的图片
                .radius(10)//模糊半径
                .scale(8)//指定模糊前缩小的倍数
                .policy(QvEasyBlur.BlurPolicy.FAST_BLUR)//使用fastBlur
                .blur();
    }

    @Override
    public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {

    }

    @Override
    public boolean equals(Object o) {
        return o instanceof GaussianBlurTransformation;
    }

}